//
//  ViewController.m
//  UI_Day01_homework
//
//  Created by aaaaaa on 16/6/3.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"


#define AWEIGHT (414 / 5.0)
#define AHEIGHT (736 / 8.0)
#define COLORARC [UIColor colorWithRed:arc4random() % 256 / 255.0 green:arc4random() % 256 / 255.0 blue:arc4random() % 256 / 255.0 alpha:1.0]

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self creatView];
//    [self homework2];
    [self homework3];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



#pragma mark - 1
- (void)creatView{
    UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 50, 50)];
    redView.backgroundColor = [UIColor redColor];
    [self.view addSubview:redView];
    [redView release];
    redView.alpha = 0.5;
    redView.hidden = NO;
    redView.tag = 1;
    
    UIView *blueView = [[UIView alloc] initWithFrame:CGRectMake(80, 20, 50, 50)];
    blueView.backgroundColor = [UIColor blueColor];
    [self.view addSubview:blueView];
    [blueView release];
    blueView.alpha = 0.5;
    blueView.hidden = NO;
    blueView.tag = 2;
    
    UIView *greenView = [[UIView alloc] initWithFrame:CGRectMake(140, 20, 50, 50)];
    greenView.backgroundColor= [UIColor greenColor];
    [self.view addSubview:greenView];
    [greenView release];
    greenView.alpha = 0.5;
    greenView.hidden = NO;
    greenView.tag = 3;
    
    UIView *yelloewView = [[UIView alloc] initWithFrame:CGRectMake(200, 20, 50, 50)];
    yelloewView.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:yelloewView];
    yelloewView.alpha = 0.5;
    yelloewView.hidden = NO;
    yelloewView.tag = 4;
    
    UIView *purpleView = [[UIView alloc] initWithFrame:CGRectMake(260, 20, 50, 50)];
    purpleView.backgroundColor = [UIColor purpleColor];
    [self.view addSubview:purpleView];
    purpleView.alpha = 0.5;
    purpleView.hidden = NO;
    purpleView.tag = 5;
    
    
}

#pragma mark - 2
- (void)homework2{
    
    self.view.backgroundColor = [UIColor grayColor];
    
    UIColor *color = [UIColor colorWithRed:46/255.0 green:1.0 blue:1.0 alpha:1.0];
    
    UIView *leftTop = [[UIView alloc] initWithFrame:CGRectMake(50, 150, 80, 30)];
    leftTop.backgroundColor = color;
    [self.view addSubview:leftTop];
    
    UIView *rightTop = [[UIView alloc] initWithFrame:CGRectMake(180, 150, 150, 30)];
    rightTop.backgroundColor = color;
    [self.view addSubview:rightTop];
    
    UIView *leftMiddle = [[UIView alloc] initWithFrame:CGRectMake(50, 220, 80, 30)];
    leftMiddle.backgroundColor = color;
    [self.view addSubview:leftMiddle];
    
    UIView *rightMiddle = [[UIView alloc] initWithFrame:CGRectMake(180, 220, 150, 30)];
    rightMiddle.backgroundColor = color;
    [self.view addSubview:rightMiddle];
    
    UIView *leftBottom = [[UIView alloc] initWithFrame:CGRectMake(100, 300, 60, 30)];
    leftBottom.backgroundColor = color;
    [self.view addSubview:leftBottom];
    
    UIView *rightBottom = [[UIView alloc] initWithFrame:CGRectMake(220, 300, 60, 30)];
    rightBottom.backgroundColor = color;
    [self.view addSubview:rightBottom];
}

#pragma mark - 3
- (void)homework3{

    for (int i = 0; i < 5 ; i++) {
        for (int j = 0; j < 8; j++) {
            UIView *view = [[UIView alloc] initWithFrame:CGRectMake(i * AWEIGHT, j * AHEIGHT, AWEIGHT, AHEIGHT)];
            view.backgroundColor = COLORARC;
            [self.view addSubview:view];
            [view release];
        }
    }
}






























@end
